package com.chenjj.bigdata.kafka;

import java.io.File;
import java.io.IOException;

public class LoginFI {

    /**
     * 用户自己申请的机机帐号keytab文件名称
     */
    private static final String USER_KEYTAB_FILE = "user.keytab";

    /**
     * 用户自己申请的机机帐号名称
     */
    private static final String USER_PRINCIPAL = "etl_user";




    public static void securityPrepare() throws IOException
    {
        String filePath = System.getProperty("user.dir") + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "fi" +File.separator;
        String krbFile = filePath + "krb5.conf";
        String userKeyTableFile = filePath + USER_KEYTAB_FILE;

        //windows路径下分隔符替换
        userKeyTableFile = userKeyTableFile.replace("\\", "\\\\");
        krbFile = krbFile.replace("\\", "\\\\");

        System.out.println(userKeyTableFile);
        System.out.println(krbFile);

        LoginUtil.setKrb5Config(krbFile);
        LoginUtil.setZookeeperServerPrincipal("zookeeper/hadoop.HADOOP.COM");
        LoginUtil.setJaasFile(USER_PRINCIPAL, userKeyTableFile);
    }

    public static void main(String[] args) {
        System.out.println(System.getProperty("user.dir") );
    }
}
